package cn.wolfcode.wolf2w.business.service.impl;

import cn.wolfcode.wolf2w.api.RemoteNoteService;
import cn.wolfcode.wolf2w.api.domain.Note;
import cn.wolfcode.wolf2w.api.domain.NoteSearch;
import cn.wolfcode.wolf2w.business.repository.NoteRepository;
import cn.wolfcode.wolf2w.business.service.INoteSearchService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 浪兎兎
 * @since 2025-06-12 15:18
 */
@Service
public class NoteSearchServiceImpl implements INoteSearchService {
    @Autowired
    private RemoteNoteService noteService;
    @Autowired
    private NoteRepository noteRepository;
    @Override
    public void initSearch() {
        List<Note> result = noteService.list("inner").getData();
        result.forEach(note -> {
            NoteSearch noteSearch = new NoteSearch();
            BeanUtils.copyProperties(note, noteSearch);
            noteRepository.save(noteSearch);
        });
    }
}
